﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SaryaAccounting
{
    /// <summary>
    /// Interaction logic for EditColor.xaml
    /// </summary>
    public partial class EditColor : Window
    {
        private double _height;
        private double _width;
        private double _top;
        private double _left;

        public EditColor()
        {
            InitializeComponent();

        }

        private void WindowCloseButton_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        private void WindowMinButton_Click(object sender, RoutedEventArgs e)
        {
            WindowState = WindowState.Minimized;
        }

        private void WindowMaxAndNormalButton_Click(object sender, RoutedEventArgs e)
        {
            if ((bool)MaxAndNormalButton.IsChecked) //Maximized State
            {
                WindowState = WindowState.Maximized;
            }
            else //Normal State
            {
                this.Height = _height;
                this.Width = _width;
                this.Top = _top;
                this.Left = _left;

                WindowState = WindowState.Normal;
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            _height = this.ActualHeight;
            _width = this.ActualWidth;
            _top = this.Top;
            _left = this.Left;
        }

        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (WindowState == WindowState.Maximized)
            {
                //if the WindowState is set to WindowState.Maximized when the WindowStyle is 'None', the window
                //will cover the taskbar. To prevent this, use code shown below

                WindowState = WindowState.Normal;
                this.Height = SystemParameters.MaximizedPrimaryScreenHeight - 5;
                this.Width = SystemParameters.MaximizedPrimaryScreenWidth - 5;
                this.Top = -5;
                this.Left = -5;

                if (!(bool)MaxAndNormalButton.IsChecked)
                    MaxAndNormalButton.IsChecked = true;
            }
        }

        private void OnDragMoveWindow(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }
    }
}
